<template>
  <view class="school">
    <view class="search">
      <image class="anniu" src="../../static/icons/search.png">
      <input type="search" placeholder="请输入学校名称" v-model="keyWord">
      <text>取消</text>
    </view>
    <text class="search-text">学校信息将会影响老师的备课和出题。</text>
    <ul>
      <li v-for="(item,index) in filList" :key="index" @click="school(index)">
        {{item.name}}--{{item.address}}
      </li>
    </ul>
  </view>
</template>

<script>
export default {
  data(){
    return {
      keyWord:'',
      list:[
        {
          name:'武汉大学',
          address:'湖北省武汉市武昌区'
        },
        {
          name:'北京大学',
          address:'北京市海淀区'
        },
        {
          name:'中国科技大学',
          address:'安徽省合肥市'
        },
        {
          name:'华中科技大学',
          address:'湖北省武汉市洪山区'
        },
        {
          name:'北京师范大学',
          address:'北京市海淀区'
        },
        {
          name:'武汉理工大学',
          address:'湖北省武汉市洪山区'
        },
        {
          name:'西北工业大学',
          address:'陕西省西安市'
        },
        {
          name:'西南大学',
          address:'重庆市北培区'
        },
        {
          name:'西北大学',
          address:'陕西省西安市碑林区'
        },
        {
          name:'陕西师范大学',
          address:'陕西省西安市雁塔区'
        },
      ]
    }
  },
  computed:{
    filList(){
      return this.list.filter((item)=>{
        return item.name.indexOf(this.keyWord) !== -1
      })
    }
  },
  methods:{
    school(index){
      console.log(this.filList[index].name);
      this.$store.state.school = this.filList[index].name
    }
  }
}
</script>

<style scoped>
  .school {
    width: 100%;
    display: flex;
    flex-direction: column;
  }
  .search {
    width: 100%;
    height: 120rpx;
    margin-top: 30rpx;
    display: flex;
    justify-content: space-around;
    align-items: center;
    /* background-color: #fff000; */
    color: #bbb;
    border-bottom:1px solid #ddd ;
    margin-bottom: 30rpx;
  }
  input{
    width: 70%;
    height: 80rpx;
    font-size: 18px;
    padding-left: 60rpx;
  }
  .anniu {
    width: 50rpx;
    height: 50rpx;
    position: absolute;
    top: 65rpx;
    left: 20rpx;
  }
  .search-text {
    margin-top: 30rpx;
    margin-left: 30rpx;
    color: #bbb;
    font-size: 15px;
  }
  li{
    margin-top: 15rpx;
    margin-left: 30rpx;
  }
</style>